package com.tengju.payment.domain.model;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;


/**
 * 全局通用交易类型
 */
@AllArgsConstructor
@Getter
public enum BusinessType {

    TRANSFER(10, "代付转账业务", TradeNoPrefix.TRANSFER_PREFIX, TradeNoPrefix.NUMBER_TRANSFER_PREFIX),
    DEP_TRANSFER(20, "存管转账业务", TradeNoPrefix.DEPOSITORY_TRANSFER_PREFIX, TradeNoPrefix.DEPOSITORY_NUMBER_TRANSFER_PREFIX);

    private int val;
    private String desc;
    private String tradeNoPrefix;
    private String numberTradeNoPrefix;

    @JsonValue
    public int getVal() {
        return val;
    }

    @JsonCreator
    public static BusinessType fromVal(int val) {
        for (BusinessType data : values()) {
            if (data.val == val) {
                return data;
            }
        }
        return null;
    }
}
